onClick Event

Description

Fires when a row in the List is clicked or when the List has focus and the user hits the Enter key.

Discussion

Your code can reference arguments[0] - the zero based index of the row that was clicked. In addition the Javascript can reference the 'this' scope, which is a pointer to the List object.

Example: Clicking List Headers and Footers

If you have defined a header or a footer for List control, and you have also defined an onClick event, you will notice that the onClick event fires when you click on either the header or the footer.

In your application, this might not be desirable. If so, then you can use the onTap event, rather than the onClick event, or alternative, in the onClick event, you can test what row index the user clicked on. The row index is 0 based, and will return -1 if the user clicked on either the header or the footer. Your onClick event would then be:

if( arguments[0] > -1) { 
    //your onClick code goes here
}

See Also